﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using Microsoft.WindowsAPICodePack.Shell;
namespace NASM_Develop_IDE
{
    public partial class IDEPreferencesWindow : GlassForm
    {
        

        public IDEPreferencesWindow()
        {

            InitializeComponent();
            TextBoxHighlighter.Highlight(generalSection.Controls["defaultPluginBinPath"]
                as TextBox, "Enter Plugin Path (Leave Blank For The Default Path)");
            AeroGlassCompositionChanged += new EventHandler<AeroGlassCompositionChangedEventArgs>(BuildDialog_AeroGlassCompositionChanged);
            if (AeroGlassCompositionEnabled)
            {
                ExcludeControlFromAeroGlass(panel);
            }
            else
            {
                BackColor = Color.Aqua;
            }
            
        }

        public IDEPreferencesWindow(IDEPreferences conf)
        {
            InitializeComponent();
            TextBoxHighlighter.Highlight(generalSection.Controls["defaultPluginBinPath"]
                as TextBox, "Enter Plugin Path (Leave Blank For The Default Path)");
            AeroGlassCompositionChanged += new EventHandler<AeroGlassCompositionChangedEventArgs>(BuildDialog_AeroGlassCompositionChanged);
            if (AeroGlassCompositionEnabled)
            {
                ExcludeControlFromAeroGlass(panel);
            }
            else
            {
                BackColor = Color.Aqua;
            }
        
           (generalSection.Controls["allowPlugins"] as CheckBox).Checked = conf.AllowPlugins;
           generalSection.Controls["defaultPluginBinPath"].Text = conf.PluginBinPath;
           projectDefaultsSection.Controls["templateEditor"].Text =conf.NASMTemplate;
          
        }

        void BuildDialog_AeroGlassCompositionChanged(object sender, AeroGlassCompositionChangedEventArgs e)
        {
            if (e.GlassAvailable)
            {
                
                ExcludeControlFromAeroGlass(panel);
                Invalidate();
            }
            else
            {
               
                this.BackColor = Color.Aqua;
            }
        }

        private void apply_Click(object sender, EventArgs e)
        {
            IDEPreferences conf = new IDEPreferences();
            conf.AllowPlugins = (generalSection.Controls["allowPlugins"] as CheckBox).Checked;
            conf.PluginBinPath = generalSection.Controls["defaultPluginBinPath"].Text;
            conf.NASMTemplate = projectDefaultsSection.Controls["templateEditor"].Text;
            conf.Save();

        }

        private void okay_Click(object sender, EventArgs e)
        {
            IDEPreferences conf = new IDEPreferences();
            conf.AllowPlugins = (generalSection.Controls["allowPlugins"] as CheckBox).Checked;
            conf.PluginBinPath = generalSection.Controls["defaultPluginBinPath"].Text;
            conf.NASMTemplate = projectDefaultsSection.Controls["templateEditor"].Text;
            conf.Save();
        }

        private void cancel_Click(object sender, EventArgs e)
        {

        }

    }
}
